<template>
<!-- <el-breadcrumb class="breadcrumb" separator="">
 <el-breadcrumb-item v-for="(item, index) in breadList" :key="index">
      <router-link v-if="item.name != name" :to="{ path: item.path }">
        {{ item.meta.title }}
      </router-link>
      <span v-else>{{ item.meta.title }}</span>
    </el-breadcrumb-item>
</el-breadcrumb> -->
<div class="back"> 
    <el-tag v-for="(item, index) in breadList" :key="index" closable type ='success'>
         <router-link v-if="item.name != name" :to="{ path: item.path }">
        {{ item.meta.title }}
      </router-link>
      <span v-else>{{ item.meta.title }}</span>
    </el-tag> 
<!-- <el-breadcrumb class="app-breadcrumb" separator="/">
    <transition-group name="breadcrumb">
      <el-breadcrumb-item v-for="(item,index) in breadList" :key="item.path">
        <span v-if="item.name != name" >{{ item.meta.title }}</span>
        <a v-else @click.prevent="handleLink(item)">{{ item.meta.title }}</a>
      </el-breadcrumb-item>
    </transition-group>
  </el-breadcrumb> -->
</div>
</template>

<script>
export default {
    data() {
      return {
        name: '',
        breadList: [],
      }
    },
  created () {
    this.getBreadcrumb()
  },
  methods: {
    getBreadcrumb() {

       const data = this.$route.matched.filter(item => item.path);

    //   this.breadList = []
    //   this.breadList.push({ name: 'home', path: '/home', meta: { title: '首页' } })
    //   this.name = this.$route.name
      data.forEach((item) => {
        // item.meta.name === 'dashboard' ? item.path = '/dashboard' : this.$route.path === item.path
          this.breadList.push(item)
      })
          console.log('this.$route.matched', this.$route.matched)

    //   console.log('this.data', data)

    }
  },
  watch: {
    $route() {
      this.getBreadcrumb()
    }
  }
}
</script>

<style scoped>
/* .app-breadcrumb.el-breadcrumb {
  display: inline-block;
  font-size: 14px;
  line-height: 50px;
  margin-left: 8px;
} */
.back {
    background-color: #fff;
}
</style>